var a = getApp();

Page({
    data: {
        language: "",
        page: 1,
        tag: "old"
    },
    onLoad: function(a) {
        a.tag && this.setData({
            tag: a.tag
        }), this.getData(this.data.page);
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        return this.data.current_page < this.data.last_page ? (wx.showLoading({
            title: "加载中",
            mask: !0
        }), this.setData({
            page: this.data.page + 1
        }), console.log(this.data.page), void this.getNext(this.data.page)) : void wx.showToast({
            title: "没有更多",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    getData: function(t) {
        var e, o = this;
        e = "new" == this.data.tag ? a.getNetAddresss("plugin.redpack-tool.frontend.quotaLog.getList") : a.getNetAddresss("plugin.red-packet.api.logs.quotaLogs"), 
        a._getNetWork({
            url: e,
            data: {
                page: t
            },
            success: function(a) {
                var t = a.data;
                "new" == o.data.tag ? o.setData({
                    quotaLogs: t.data.quota_logs.data,
                    member: t.data.member,
                    receive_logs: t.data.quota_info,
                    resmun: t.data.quota_info.surplus_total.toFixed(2),
                    current_page: t.data.quota_logs.current_page,
                    last_page: t.data.quota_logs.last_page
                }) : o.setData({
                    quotaLogs: t.data.quotaLogs.data,
                    member: t.data.member,
                    receive_logs: t.data.receive_logs,
                    resmun: (t.data.receive_logs.amount_sum - t.data.receive_logs.receive_amount).toFixed(2),
                    current_page: t.data.quotaLogs.current_page,
                    last_page: t.data.quotaLogs.last_page
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getNext: function(t) {
        var e, o = this;
        e = "new" == this.data.tag ? a.getNetAddresss("plugin.redpack-tool.frontend.quotaLog.getList") : a.getNetAddresss("plugin.red-packet.api.logs.quotaLogs"), 
        a._getNetWork({
            url: e,
            data: {
                page: t
            },
            success: function(a) {
                var t = a.data;
                "new" == o.data.tag ? t.data.quota_logs.current_page > t.data.quota_logs.last_page ? (wx.hideLoading(), 
                wx.showToast({
                    title: "没有更多",
                    icon: "none"
                }), o.setData({
                    current_page: t.data.quota_logs.current_page,
                    last_page: t.data.quota_logs.last_page
                })) : (wx.hideLoading(), o.setData({
                    quotaLogs: o.data.quotaLogs.concat(t.data.quota_logs.data),
                    current_page: t.data.quota_logs.current_page,
                    last_page: t.data.quota_logs.last_page
                })) : t.data.quotaLogs.current_page > t.data.quotaLogs.last_page ? (wx.hideLoading(), 
                wx.showToast({
                    title: "没有更多",
                    icon: "none"
                }), o.setData({
                    current_page: t.data.quotaLogs.current_page,
                    last_page: t.data.quotaLogs.last_page
                })) : (wx.hideLoading(), o.setData({
                    quotaLogs: o.data.quotaLogs.concat(t.data.quotaLogs.data),
                    member: t.data.member,
                    receive_logs: t.data.receive_logs,
                    current_page: t.data.quotaLogs.current_page,
                    last_page: t.data.quotaLogs.last_page
                }));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    }
});